﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace Http
{
    public partial class HttpRequesst
    {
        /// <summary>
        /// 返回内容中关键字匹配次数
        /// </summary>
        /// <param name="content">内容</param>
        /// <returns>匹配次数</returns>
        private double ColligateContent(string content)
        {
            double count = 0;
            if (content != null && content != string.Empty)
            {
                for (int i = 0; i < keyword.Count; i++)
                {
                    if (content.Contains(keyword[i].ToString()))
                    {
                        count++;
                    }
                }
            }
            double countSplt = keyword.Count / 50;  //得出每段权重
            return count = count / countSplt / 10;  //得出五分制结果
        }

        /// <summary>
        /// Google 收录
        /// </summary>
        /// <param name="domain">域名</param>
        /// <returns>收录数量</returns>
        private double GetGoogleEmbody(string domain)
        {
            return 0;
        }

        /// <summary>
        /// 获取GooglePR值
        /// </summary>
        /// <param name="domain">域名</param>
        /// <returns>PR值</returns>
        private double GetGooglePR(string domain)
        {
            return 0;
        }

        /// <summary>
        /// Baidu 收录
        /// </summary>
        /// <param name="domain">域名</param>
        /// <returns>收录数量</returns>
        private double GetBaiduEmbody(string domain)
        {
            return 0;
        }

        /// <summary>
        /// 获取Destoon网站评分,分值越高相似度越高
        /// </summary>
        /// <param name="content">网页内容</param>
        /// <returns>相似度分值</returns>
        private double GetDestoonScore(string content)
        {
            string[,] src = new string[,]{ {"5","上网做生意，首选VIP会员"}, 
                {"1","WAP浏览"},
                {"1","WAP收藏本页"},
                {"1","RSS订阅"},
                {"2","商务中心"},
                {"2","发布信息"},
                {"2","排名推广"},
                {"1","请输入关键字"},
                {"4","免费注册为会员后，您可以..."},
                {"2","在线洽谈生意"},
                {"2","推广企业产品"},
                {"2","发布供求信息"},
                {"3","还不是会员，立即免费注册"},
                {"3","Destoon"}};
            double score = 0;
            try
            {
                for (int i = 0; i < 14; i++)
                {
                    if (content.Contains(src[i, 1].ToString()))
                    {
                        score += Convert.ToDouble(src[i, 0].ToString());
                    }
                }
                return score;
            }
            catch (Exception ex)
            {
                return 0;
            }            
        }

        /// <summary>
        /// 关键字集合
        /// </summary>
        private List<string> keyword = new List<string>();
    }
}